package com.nine.pesys.model.entity;


import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by L先森 on 2015/1/4.
 */
@Entity
@Table(name = "tb_sportFieldDetail")
public class SportFieldDetail implements Serializable {
    private Long id;
    private Boolean isSchool;
    private Boolean isReserved;
    private Boolean isGame;

    private SportField sportField;
    private Set<FileInformation> fileInformations = new HashSet<FileInformation>();

    @Id
    @Column(name = "id",length = 10)
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column
    public Boolean getIsSchool() {
        return isSchool;
    }

    public void setIsSchool(Boolean isSchool) {
        this.isSchool = isSchool;
    }

    @Column
    public Boolean getIsReserved() {
        return isReserved;
    }

    public void setIsReserved(Boolean isReserved) {
        this.isReserved = isReserved;
    }

    @Column
    public Boolean getIsGame() {
        return isGame;
    }

    public void setIsGame(Boolean isGame) {
        this.isGame = isGame;
    }

    @ManyToOne(targetEntity = SportField.class,cascade = CascadeType.MERGE)
    @JoinColumn(name = "sportFieldId")
    public SportField getSportField() {
        return sportField;
    }

    public void setSportField(SportField sportField) {
        this.sportField = sportField;
    }

    @OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL)
    @JoinColumn(name = "sportFieldDetailId")
    public Set<FileInformation> getFileInformations() {
        return fileInformations;
    }

    public void setFileInformations(Set<FileInformation> fileInformations) {
        this.fileInformations = fileInformations;
    }

    @Override
    public String toString() {
        return "SportFieldDetail{" +
                "id=" + id +
                ", isSchool=" + isSchool +
                ", isReserved=" + isReserved +
                ", isGame=" + isGame +
                ", sportField=" + sportField +
                ", fileInformations=" + fileInformations +
                '}';
    }
}
